<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                xmlns:security="http://www.springframework.org/security/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">外部融合页贷款专区统计</ui:define>
    <ui:define name="content">
        <h:form>
            <p:defaultCommand target="search"/>
            <div class="topbar clearfix"
                 style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="left">
                        <p:commandButton id="toggler" type="button" value="展示选择"
                                         style="width: auto;"
                                         icon="ui-icon-calculator"
                                         rendered="#{security:areAllGranted('EXTERNAL_LOAN_AREA_STATISTIS_SEARCH')}"/>
                        <p:columnToggler datasource="smsStatistisDataTable" trigger="toggler"
                                         rendered="#{security:areAllGranted('EXTERNAL_LOAN_AREA_STATISTIS_SEARCH')}"/>
                    </f:facet>
                    <f:facet name="right">
                        <p:commandButton id="search" value="查询" icon="fa fa-search"
                                         update="@form"
                                         rendered="#{externalLoanAreaStatistsBean.isNormal() and security:areAllGranted('EXTERNAL_LOAN_AREA_STATISTIS_SEARCH')}"/>
                         <p:commandButton value="导出" icon="fa fa-download"
                                         rendered="#{externalLoanAreaStatistsBean.isNormal() and security:areAllGranted('EXTERNAL_LOAN_AREA_STATISTIS_EXPORT')}"
                                         ajax="false">
                            <p:dataExporter type="xls" target="smsStatistisDataTable" fileName="export"/>
                        </p:commandButton>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-fluid" style="padding-top: 30px;">
                <div class="ui-g">
                    <div class="ui-g-12">
                        <div class="card ui-g-12">
                            
                            <div class="ui-g-1">
                           		<p:outputLabel value="联登时间"/>
	                        </div>
	                        <div class="ui-g-5">
	                            <p:calendar value="#{externalLoanAreaStatistsBean.$.unionLoginStartDate}"
	                                        styleClass="autoWidthCalendar"
	                                        locale="#{constants:get('LOCALE')}"
	                                        timeZone="#{constants:get('TIME_ZONE')}"
	                                        pattern="#{constants:get('DATE_FORMAT')}"/>
	                            <span>—</span>
	                            <p:calendar value="#{externalLoanAreaStatistsBean.$.unionLoginEndDate}"
	                                        styleClass="autoWidthCalendar"
	                                        locale="#{constants:get('LOCALE')}"
	                                        timeZone="#{constants:get('TIME_ZONE')}"
	                                        pattern="#{constants:get('DATE_FORMAT')}"/>
	                        </div>
	                                       
	                        <div class="ui-g-1">
	                           	<p:outputLabel value="产品"/>
	                        </div>
	                        <div class="ui-g-5">
	                            <p:selectOneMenu
	                                    value="#{externalLoanAreaStatistsBean.$.productId}" filter="true"
	                                    filterMatchMode="contains">
	                                <f:selectItem itemLabel="- 请选择 -" itemValue=""
	                                              noSelectionOption="true"/>
	                                <f:selectItems
	                                        value="#{externalLoanAreaStatistsBean.dictionaries[DictionaryCode.EXTERNAL_LOAN_AREA_PRODUCT]}"
	                                        var="dic"
	                                        itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
	                            </p:selectOneMenu>
	                        </div>
	                                 
                    	</div>
                                 
                        <div class="card">
                            <p:dataTable id="smsStatistisDataTable"
                                         style="width: 100%"
                                         var="record"
                                         value="#{externalLoanAreaStatistsBean.lazyDataModel}"
                                         rows="#{constants:get('ROWS')}"
                                         lazy="true"
                                         paginator="true"
                                         paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                         rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                         emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                         scrollable="true"
                                         scrollWidth="97%"
                                         reflow="true"
                                         selection="#{externalLoanAreaStatistsBean.selectedRecords}"
                                         resizableColumns="true"
                                         rendered="#{security:areAllGranted('EXTERNAL_LOAN_AREA_STATISTIS_SEARCH')}">

                                <p:column headerText="联登时间">
                                    <h:outputText value="#{record.unionLoginDate}">
                                        <f:convertDateTime pattern="#{constants:get('DATE_FORMAT')}"/>
                                    </h:outputText>
                                </p:column>
                               
                                <p:column headerText="产品">
                                    <h:outputText value="#{externalLoanAreaStatistsBean.translate(DictionaryCode.EXTERNAL_LOAN_AREA_PRODUCT, record.productId)}"/>
                                </p:column>
                                
                                <p:column headerText="专区访问UV">
                                    <h:outputText value="#{record.viewAreaUV}"/>
                                </p:column>
                                
                                <p:column headerText="首次联登人数">
                                    <h:outputText value="#{record.firstUnionLoginCount}"/>
                                </p:column>
                                
                                <p:column headerText="登录人数">
                                    <h:outputText value="#{record.loginCount}"/>
                                </p:column>
                                
                            </p:dataTable>
                        </div>
                    </div>
                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>
